﻿using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SetVersionNumber;
using SetVersionNumber.VersionStrategies;

namespace SetVersionNumberTests {

	/// <summary>
	/// All of the unit tests for the <c>FileVersionUpdater</c> class.
	/// </summary>
	[TestClass]
	public class FileVersionUpdaterTests {

		[TestMethod]
		public void ConstructorFindsEmbeddedFileUpdaters( ) {
			var sut = new FileVersionUpdater();
			var count = sut.FileUpdaters.Count();
			Assert.IsTrue(count>=1, "Failed to find any file updaters");
		}


		[TestMethod]
		public void ConstructorFindsEmbeddedVersionStrategies( ) {
			var sut = new FileVersionUpdater();
			var count = sut.VersionStrategies.Count();
			Assert.IsTrue(count>=1, "Failed to find any version strategies");
		}


		[TestMethod]
		public void FindStrategyDoesNotFindAStrategyWithABadName( ) {
			var sut = new FileVersionUpdater();
			var strategy = sut.FindStrategyByName("No such strategy");
			Assert.IsNull(strategy, "Should NOT have found the strategy with the given name.");
		}


		[TestMethod]
		public void FindKnownGoodStrategyByNameReturnsExpectedStrategy( ) {
			var sut = new FileVersionUpdater();
			var strategy = sut.FindStrategyByName(ExplicitVersionStrategy.NAME);
			Assert.IsNotNull(strategy, "Should have found the strategy with the given name.");
			Assert.IsInstanceOfType(strategy, typeof(ExplicitVersionStrategy), "The returned strategy is not the correct type");
		}

	}//class

}//namespace
